//
//  APIEnergyDispatchManager.m
//  cocoapodText
//
//  Created by apple on 16/10/21.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "NetTool.h"
#import "AFNetworking.h"
#import "APIEnergyDispatchManager.h"

@interface APIEnergyDispatchManager()

@end
@implementation APIEnergyDispatchManager

-(void)fsgy_api_energy_dispatch_withFalg:(NSString *)falg planIden:(NSString *)planIden{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_dispatch];
    NSDictionary *params=@{@"action":@"searchTable",@"planIden":planIden};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onEnergyDispatchManager:result:Flag:)]){
            [_delegate onEnergyDispatchManager:self result:responseObject Flag:falg];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
    }];
}

-(void)fsgy_api_energy_dispatch_withFalg:(NSString *)falg planIden:(NSString *)planIden pageNum:(NSString *)pageNum pageRecord:(NSString *)pageRecord{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_dispatch];
    NSDictionary *params=@{@"action":@"searchTable",@"planIden":planIden,@"pageNum":pageNum,@"pageRecord":pageRecord};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onEnergyDispatchManager:result:Flag:)]){
            [_delegate onEnergyDispatchManager:self result:responseObject Flag:falg];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
    }];
}

@end
